/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	AStoreQueryParamConverter.java
 * Created：		2016年9月5日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.common;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.spi.common.SStoreQueryParam;

/**
 * @author wolv
 *
 */
public class SStoreQueryParamConverter implements Converter<AStoreQueryParam, SStoreQueryParam> {

	public static SStoreQueryParamConverter getInstance() {
		if (instance == null)
			instance = new SStoreQueryParamConverter();
		return instance;
	}

	private static SStoreQueryParamConverter instance;

	private SStoreQueryParamConverter() {
	}

	@Override
	public SStoreQueryParam convert(AStoreQueryParam source) {
		if (source == null)
			return null;

		SStoreQueryParam target = new SStoreQueryParam();
		target.setPage(source.getPage());
		target.setPageSize(source.getPageSize());
		target.setStores(new ArrayList<String>());
		if (source.getStores() != null)
			target.getStores().addAll(source.getStores());
		target.setOrder(source.getOrder());

		return target;
	}

}
